/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package cn.knet.sp.ncrm.modules.customer.potentialdistrecord.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import cn.knet.sp.ncrm.common.persistence.Page;
import cn.knet.sp.ncrm.common.service.CrudService;
import cn.knet.sp.ncrm.common.utils.StringUtils;
import cn.knet.sp.ncrm.modules.customer.potentialdistrecord.dao.PotentialDistRecordDao;
import cn.knet.sp.ncrm.modules.customer.potentialdistrecord.entity.PotentialDistRecord;
import cn.knet.sp.ncrm.modules.customer.potentialdistrecord.vo.PotentialDistRecordVo;

/**
 * 分配记录Service
 *
 * @author 葛海洋
 * @version 2015-08-26
 */
@Service
@Transactional(readOnly = true)
public class PotentialDistRecordService extends CrudService<PotentialDistRecordDao, PotentialDistRecord> {

	public PotentialDistRecord get(String id) {
		return super.get(id);
	}

	public List<PotentialDistRecord> findList(PotentialDistRecord potentialDistRecord) {
		return super.findList(potentialDistRecord);
	}

	/**
	 * 根据潜在客户id 查询该id 下所有的分配记录
	 */
	public List<PotentialDistRecord> findList(String potentialCustomerId) {
		PotentialDistRecord potentialDistRecord = new PotentialDistRecord();
		potentialDistRecord.setPotentialCustomerId(potentialCustomerId);
		return super.findList(potentialDistRecord);
	}

	/**
	 * 根据 对象内的id ，动态查询 查询vo 对象
	 * @author fengyapeng
	 * @since 2015 /08/31 18:16:47
	 * @param potentialDistRecord the potential dist record
	 * @return the list
	 */
	public List<PotentialDistRecordVo> findVoList(PotentialDistRecord potentialDistRecord) {
		if (StringUtils.isBlank(potentialDistRecord.getPage().getOrderBy())) {
			potentialDistRecord.getPage().setOrderBy("a.last_updated desc");
		}
		return this.dao.findVoList(potentialDistRecord);
	}

	public Page<PotentialDistRecord> findPage(Page<PotentialDistRecord> page, PotentialDistRecord potentialDistRecord) {
		return super.findPage(page, potentialDistRecord);
	}

	@Transactional(readOnly = false)
	public void save(PotentialDistRecord potentialDistRecord) {
		super.save(potentialDistRecord);
	}

	@Transactional(readOnly = false)
	public void delete(PotentialDistRecord potentialDistRecord) {
		super.delete(potentialDistRecord);
	}

}